package com.bamboo.core.exceptions;

import com.bamboo.core.enums.code.ICodeEnum;

/**
 * @author chenzh
 * @description 框架的基础异常类
 * @date 2025/3/6 11:48
 */
public class BambooException extends RuntimeException {
    protected int code;

    public BambooException() {
    }

    public BambooException(ICodeEnum codeEnum, String message) {
        super(message);
        this.code = codeEnum.getCode();
    }

    public BambooException(ICodeEnum codeEnum) {
        super(codeEnum.getMsg());
        this.code = codeEnum.getCode();
    }

    public BambooException(String message) {
        super(message);
    }

    /**
     * @description 嵌套一层当前异常同时补充异常信息
     * @param message 当前异常的信息
     * @param cause 原始异常
     */
    public BambooException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * @description 嵌套一层当前的异常
     * @param cause 原始异常
     */
    public BambooException(Throwable cause) {
        super(cause);
    }


    public int getCode() {
        return code;
    }
}
